import React, {Component} from "react";
import {Helmet} from 'react-helmet';
import UserCenter from "../component/user-center";
import {HashRouter as Router, Route} from "react-router-dom";
import AppCenter from "./app-center/index";
import {connect} from 'react-redux'
import image from '../image/favicon-32x32.png';
import EmailResetCenter from './email-reset-center'
import locales from '../locales'
import 'antd/dist/antd.css';
import {IntlProvider} from "react-intl";
import {LocaleProvider} from "antd";
import {getLangFromLocalStorage} from '../constant/lang-util'

class App extends Component {
    render() {
        const lang = this.props.lang || getLangFromLocalStorage()
        const langData = locales[lang]

        return (
            <div id="root">
                <Helmet>
                    <meta charSet="utf-8"/>
                    <title>思特沃克学习平台 | ThoughtWorks Learning Platform</title>
                    <link rel="icon" type="image/png" sizes="32x32" href={image}/>
                </Helmet>
                <IntlProvider locale={langData.intlLocale} messages={langData.intlMessage}>
                    <LocaleProvider locale={langData.locale}>
                <Router>
                    <div>
                        <Route exact path="/" component={UserCenter}/>
                        <Route path='/app-center' component={AppCenter}/>
                        <Route path='/email-reset/:uuid' component={EmailResetCenter}/>
                    </div>
                </Router>
                    </LocaleProvider>
                </IntlProvider>
            </div>
        );
    }
}

const mapStateToProps = ({lang}) => ({lang})

export default connect(mapStateToProps)(App)

